package com.xuan.modules.system.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xuan.commons.api.Result;
import com.xuan.modules.system.entity.CoCompany;
import com.xuan.modules.system.service.CoCompanyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.management.Query;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-05-24
 */
@RestController
@RequestMapping("/company")
@Api(value = "CoCompany对象",tags = "CoCompany对象")
public class CoCompanyController {

    @Autowired
    private CoCompanyService coCompanyService;


    @GetMapping("/list")
    @ApiOperation(value = "查询全部",notes = "")
    public Result<?> list(CoCompany coCompany,
                                         @RequestParam(name = "currentPage",defaultValue = "1") Integer currentPage,
                                         @RequestParam(name = "pageSize",defaultValue = "10") Integer pageSize){
        Page<CoCompany> page = new Page<>(currentPage,pageSize);
        IPage<CoCompany> iPage = coCompanyService.page(page);
        return Result.ok(iPage);
    }
    @PostMapping("/save")
    @ApiOperation(value = "新增",notes = "")
    public Result save(@RequestBody CoCompany coCompany){
        return Result.status(coCompanyService.save(coCompany));
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改",notes = "")
    public Result update(@RequestBody CoCompany coCompany){
        return Result.status(coCompanyService.updateById(coCompany));
    }
    @PostMapping("/delete")
    @ApiOperation(value = "修改",notes = "")
    public Result delete(String id){
        return Result.status(coCompanyService.removeById(id));
    }
}

